package com.upay.android.client.handler;

import com.upay.android.client.activity.AbstractUPayActivity;
import com.upay.android.util.exception.RestException;
import com.upay.domain.response.ResponseEnvelope;

public abstract class AbstractCallbackHandler<T extends Object> implements CallbackHandler<T> {

	/* ---- Constants ---- */
	
	/* ---- Instance Variables ---- */
	protected AbstractUPayActivity context = null;
	
	/* ---- Constructors ---- */
	
	/* ---- Business Methods ---- */
	
	@Override
	public void handleRestException(RestException exception) {
		context.processRestException(exception);
	}

	@Override
	public void handleProgramException(ResponseEnvelope<T> response) {
		context.processProgramException(response);
	}


    /* ---- Getters and Setters ---- */
	
	/**
	 * @return the context
	 */
	protected AbstractUPayActivity getContext() {
		return context;
	}

	/**
	 * @param context the context to set
	 */
	protected void setContext(AbstractUPayActivity context) {
		this.context = context;
	}

}
